{extend name="./common/base"}
{block name="content"}
<div class="panel admin-panel">
    <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>增加内容</strong></div>
    <div class="body-content">
        <form method="post" class="form-x" action="">
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">商品名称</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" name="goods_name" value="{$data['goods_name']}">
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">所属分类</label>
                <div class="col-sm-10">
                    <select name="cate_id" class="input w50">
                        <option value="">--所属分类--</option>
                        {foreach $oldData as $vo}
                        <option {if condition="$data['cate_id']==$vo['cate_id']"} selected {/if} value="{$vo.cate_id}">{$vo.cate_name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">今日新品</label>
                <div class="col-sm-10">
                    <input type="radio" class="form-control" name="goods_new"{if condition="$data['goods_new']==1"} selected {/if}  value="1">是
                    <input type="radio" class="form-control" name="goods_new"{if condition ="$data['goods_new']==0"}selected{/if} value="0">否
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">一周热销</label>
                <div class="col-sm-10">
                    <input type="radio" class="form-control" name="goods_hotsell"{if condition="$data['goods_hotsell']==1"}selected{/if} value="1">是
                    <input type="radio" class="form-control" name="goods_hotsell"{if condition="$data['goods_hotsell']==0"}selected{/if} value="0">否
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">热销单品</label>
                <div class="col-sm-10">
                    <input type="radio" class="form-control" name="goods_hotitem"{if condition="$data['goods_hotitem']==1"}selected{/if} value="1">是
                    <input type="radio" class="form-control" name="goods_hotitem"{if condition="$data['goods_hotitem']==0"}selected{/if} value="0">否
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">每日特价</label>
                <div class="col-sm-10">
                    <input type="radio" class="form-control" name="goods_daily"{if condition="$data['goods_daily']==1"}selected{/if} value="1">是
                    <input type="radio" class="form-control" name="goods_daily"{if condition="$data['goods_daily']==0"}selected{/if} value="0">否
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">好物专题</label>
                <div class="col-sm-10">
                    <input type="radio" class="form-control" name="goods_good"{if condition="$data['goods_good']==1"}selected{/if} value="1">是
                    <input type="radio" class="form-control" name="goods_good"{if condition="$data['goods_good']==0"}selected{/if} value="0">否
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">美丽优选</label>
                <div class="col-sm-10">
                    <input type="radio" class="form-control" name="goods_choice"{if condition="$data['goods_choice']==1"}selected{/if} value="1">是
                    <input type="radio" class="form-control" name="goods_choice"{if condition="$data['goods_choice']==0"}selected{/if} value="0">否
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">市场价</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" name="goods_sprice" value="{$data['goods_sprice']}">
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">商城价</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" name="goods_mprice" value="{$data['goods_mprice']}">
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">库存数量</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" name="goods_num" value="{$data['goods_num']}">
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">颜色</label>
                <div class="col-sm-10">
                    <textarea class="form-control"  name="goods_color"  value=""  cols="30" rows="10" placeholder="红色|白色|蓝色">{$data['goods_color']}</textarea>
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label" >尺码</label>
                <div class="col-sm-10">
                    <textarea class="form-control" cols="30" rows="10" name="goods_size" valu="{$data['goods_size']}">
                        {$data['goods_color']}
                    </textarea>
                    <span class="help-block">请按照：S|M|L  输入</span>
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">上架时间</label>
                <div class="layui-inline">
                    <input class="layui-input"  name="goods_createtime"  value="{$data['goods_createtime']}"   placeholder="自定义日期格式" onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
                </div>
            </div>
            <script src="__STATIC__/layui/layui.js" type="text/javascript"></script>
            <script>
                layui.use('laydate', function(){
                    var laydate = layui.laydate;
                });
            </script>

            <div class="form-group">
                <label for="" class="col-sm-2 control-label">列表图</label>
                <div class="col-sm-10">
                    <div class="input-group">
                        <input type="text" class="form-control" name="goods_thumb" readonly="" value="{$data['goods_thumb']}">
                        <div class="input-group-btn">
                            <button onclick="upImage(this)" class="btn btn-default" type="button">选择图片</button>
                        </div>
                    </div>
                    <div class="input-group" style="margin-top:5px;">
                        <img {if condition="!$data['goods_thumb']"} src="__STATIC__/node_modules/hdjs/images/nopic.jpg" {else /}src="__STATIC__/../{$data['goods_thumb']}"{/if} class="img-responsive img-thumbnail" width="150">
                        <em class="close" style="position:absolute; top: 0px; right: -14px;" title="删除这张图片"
                            onclick="removeImg(this)"></em>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">商品图册</label>
                <button onclick="upManyImage(this)" class="btn btn-default" type="button">选择图片</button>
                <div id="box">
                    <?php foreach(explode('|',$data['goods_pics']) as $vo){?>
                    <li>
                        <img src="__STATIC__/../{$vo}" alt="">
                        <input type="hidden" name="goods_pics[]" value="{$vo}">
                    </li>
                    <?php } ?>
                </div>
            </div>
            <script>
                //上传图片
                function upManyImage(obj) {
                    require(['util'], function (util) {
                        options = {
                            //上传多图
                            multiple: true,
                        };
                        util.image(function (images) {
                            $(images).each(function (k, v) {
//                                          $("<img src='"+v+"'/>").appendTo('#box');
                                var li = "<li>"
                                li += "<img src='__STATIC__/../" + v + "'/>";
                                li += '<input type="hidden" name="goods_pics[]" value="' + v + '">';
                                li += "</li>";
                                $(li).appendTo('#box');
                            })
                        }, options)
                    });
                }
            </script>
            <style>
                #box li{
                    list-style: none;
                    float: right;
                }
            </style>
            <div class="clear"></div>

            <div class="form-group">
                <label for="" class="col-sm-2 control-label">商品详情</label>
                <div class="col-sm-10">
                    <textarea id="container" style="height:300px;width:100%;" name="goods_details" value="{$data['goods_details']}">{$data['goods_details']}</textarea>
                    <script>
                        util.ueditor('container', {hash:2,data:'hd'}, function (editor) {
                            //这是回调函数 editor是百度编辑器实例
                        });
                    </script>
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-10">
                    <input type="hidden" class="form-control" name="goods_isrecycle" value="1">
                    <!--<input type="text" class="form-control" name="goods_isrecycle" value="1" >-->
                </div>
            </div>

            <div class="form-group">
                <div class="label">
                    <label></label>
                </div>
                <div class="field">
                    <button class="button bg-main icon-check-square-o" type="submit"> 提交</button>
                </div>
            </div>
        </form>
        <script>
            //上传图片
            function upImage(obj) {
                require(['util'], function (util) {
                    options = {
                        multiple: false,//是否允许多图上传
                        //data是向后台服务器提交的POST数据
                        data: {name: '后盾人', year: 2099},
                    };
                    util.image(function (images) {          //上传成功的图片，数组类型

                        $("[name='goods_thumb']").val(images[0]);
                        $(".img-thumbnail").attr('src', '__STATIC__/../' + images[0]);
                    }, options)
                });
            }


            //移除图片
            function removeImg(obj) {
                $(obj).prev('img').attr('src', '__STATIC__/node_modules/hdjs/images/nopic.jpg');
                $(obj).parent().prev().find('input').val('');
            }
        </script>
    </div>
</div>
{/block}